import { pick } from 'lodash-es'
import { computed } from 'vue'
const stylaNameToPX = ['fontSize']
export const useComponentCommon = (props: { [key: string]: any}, picks: string[]) => {
  const styleProps = computed(() => pick(props, picks))
  Object.keys(styleProps.value).forEach(key => {
    if(stylaNameToPX.includes(key)){
      styleProps.value[key] = `${styleProps.value[key]}px`
    }
  })
  const handleClick = () => {
    if(props.actionType === 'url' && props.url && !props.isEditingProp) {
      window.location.href = props.url
    }
  }
  return {
    styleProps,
    handleClick
  }
}